package cn.anquing.rabbitmq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/mq")
public class Controller {

    @Autowired
    private MQSender mqSender;

    @GetMapping("/queue")
    public String mq(@RequestParam String message){
        mqSender.send(message);
        return message;
    }

    @GetMapping("/topic")
    public String topic(@RequestParam String message){
        mqSender.sendTopic(message);
        return message;
    }

    @GetMapping("/fanout")
    public String fanout(@RequestParam String message){
        mqSender.sendFanout(message);
        return message;
    }

    @GetMapping("/header")
    public String header(@RequestParam String message){
        mqSender.sendHeader(message);
        return message;
    }
}
